package net.avh4.scratch.rpg.model;

public class Stat {
	
	int value;
	int maxValue;
	
	public Stat(int value, int maxValue) {
		this.value = value;
		this.maxValue = maxValue;
	}
	
	public void adjust(int delta) {
		value += delta;
		if (value > maxValue) value = maxValue;
		if (value < 0) value = 0;
	}
	
	public void adjustMax(int delta) {
		maxValue += delta;
		if (maxValue < 0) maxValue = 0;
		if (value > maxValue) value = maxValue;
	}
	
	@Override
	public String toString() {
		return Integer.toString(value) + "/" + Integer.toString(maxValue);
	}

	public double getPercent() {
		return (float) value / (float) maxValue;
	}
	
	public Stat clone() {
		return new Stat(this.value, this.maxValue);
	}

}
